package com.lyz.dataStructure.algorithm.腾讯面试2020;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 20:21
 * @Description:
 **/

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/9/20 20:21
 *@Description:
 **/
public class 企鹅王国 {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        List list = new ArrayList();
        for(int i=0;i<t;i++){
           int  m = sc.nextInt();
           String  s = sc.nextLine();
           list.add(yesOrNo(s,m)) ;
        }
        for(int i =0;i<list.size();i++){
            System.out.println(list.get(i));
        }
    }

    public static boolean yesOrNo(String s,int m){
        if(s.length()==0||s==null){
            return false;
        }
        boolean flag = false;
        int i = 0;
        while (m-i>=11){
           if(s.charAt(i)=='8'){
               flag = true;
               break;
           }else {
               i++;
           }
       }
       return flag;
    }
}
